from sqlalchemy import create_engine
from sqlalchemy.ext.asyncio import create_async_engine

# db_config = {  # 一汽丰田正式
#     'host': 'bj-cdb-pr2xxnfm.sql.tencentcdb.com',
#     'port': 59584,
#     'user': 'root',
#     'password': 'Ftms@2024',
#     'database': 'toyota_yi_feng',
# }

db_config = {  # 一汽丰田正式——内网
    'host': '172.16.0.9',
    'port': 3306,
    'user': 'root',
    'password': 'Ftms@2024',
    'database': 'toyota_yi_feng',
}

# 创建数据库连接池
engine = create_engine(
    'mysql+pymysql://',
    connect_args=db_config,
    pool_size=4000,  # 最大连接数
    pool_pre_ping=False,  # 每次连接被取出时都检查连接是否有效
)

# 异步连接引擎
async_engine = create_async_engine(
    'mysql+aiomysql://', connect_args=db_config, pool_size=10000
)
